package com.mz.ozy.widget.dialog;

import android.app.Activity;
import android.content.Context;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.mz.ozy.R;
import com.mz.ozy.utils.ToastUtils;

public class OrderConfirmPayDialog extends BaseDialog implements View.OnClickListener {

    private EditText mEtDescribeMsg;
    private TextView mTvGoodsPrice;
    private TextView mTvBalance;
    private String ktbalance;
    private String price;
    private String xfbalance;
    private int priceType;

    public OrderConfirmPayDialog(Activity mContext) {
        super(mContext, R.layout.dialog_order_confirm_pay, Gravity.BOTTOM, true, true);
        initView();
    }

    private void initView() {
        setOnViewClick(R.id.iv_cancel, this);
        setOnViewClick(R.id.tv_submit, this);
        mEtDescribeMsg = getView(R.id.et_describe_msg);
        mTvGoodsPrice = getView(R.id.tv_goods_price);
        mTvBalance = getView(R.id.tv_balance);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_cancel:
                if (mListener != null) {
                    mListener.onCancel();
                }
                break;
            case R.id.tv_submit:
                if (mListener != null) {
//                    String msg = mEtDescribeMsg.getText().toString().trim();
//                    if (!TextUtils.isEmpty(msg)) {
                    mListener.onSubmit(null);
//                    } else {
//                        ToastUtils.showToast("支付密码不能为空");
//                    }
                }
                break;
        }
    }

    private onDialogListener mListener;

    public void setOnDialogListener(onDialogListener listener) {
        mListener = listener;
    }

    public void setBalance(String ktbalance, String xfbalance, String price, int priceType) {
        this.ktbalance = ktbalance;
        this.xfbalance = xfbalance;
        this.price = price;
        this.priceType = priceType;
        setViewData();
    }

    private void setViewData() {
        mTvBalance.setText("¥" + ktbalance);
        if (!TextUtils.isEmpty(price)) {
            mTvGoodsPrice.setText("¥" + price);
        }
    }

    public interface onDialogListener {
        void onCancel();

        void onSubmit(String id);
    }
}
